{
 "cells": [
  {
   "cell_type": "raw",
   "id": "b30ea9f5",
   "metadata": {},
   "source": [
    "关联规则：一个事务发生时另外一个事务也会随之发生。那么我们就认为两个事务之间存在关联规则。\n",
    "      阈值：当两个事务同时发生的概率超过了设定阈值后就认为两个事务之间存在关联规则。没有固定值。要根据不同业务场景制定。\n",
    "关联规则：关联规则一般提供的数据是没有列名的\n",
    "        原理：发现事物之间的关联性，可以定义为某个事件发生另外的事件就会随之发生\n",
    "        怎么发现事物之间存在关联性：\n",
    "            两个事物同时发生的概率非常高，就可以定义为两个事物之间存在关联性(关联规则)\n",
    "        名词解释：\n",
    "            项集：就是项的集合，每一项就对应着一个事物\n",
    "            频繁项集：满足最小支持度的项集就是频繁项集。也就是满足关联规则\n",
    "                      频繁项集可以是多个，一个事物不是频繁一项集，那么也就一定不能构成频繁二项集、三项集....\n",
    "            支持度：表示物品同时出现的次数占整体记录数的比例\n",
    "            置信度：物品X和物品Y同时出现的次数占物品X出现次数的比例，可以计算出物品X和Y之间的关联关系\n",
    "            提升度：表示含有X的条件下同时含有Y的概率，占Y总体发生的概率。用于判断事物之间是否存在强关联规则。强关联规则认为\n",
    "                    如果X和Y存在强关联规则，X发生时Y一定会发生\n",
    "        实现算法：\n",
    "            Apriori算法:\n",
    "            FP-growth算法:\n",
    "            PrefixSpan算法:构成的频繁项集会形成一颗树"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ce7c62a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e29ac9d9",
   "metadata": {},
   "source": [
    "1.读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4a076b62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>fruit</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>apple ,banana</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Orange ,banana,apple</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Orange ,banana,grape</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>grape ,apple</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>pineapple ,Orange</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>pineapple,banana,pear</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>pear ,apple</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>pear,banana ,grape</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>grape,pineapple</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ID                  fruit\n",
       "0   1         apple ,banana \n",
       "1   2   Orange ,banana,apple\n",
       "2   3  Orange ,banana,grape \n",
       "3   4           grape ,apple\n",
       "4   5      pineapple ,Orange\n",
       "5   6  pineapple,banana,pear\n",
       "6   7            pear ,apple\n",
       "7   8    pear,banana ,grape \n",
       "8   9        grape,pineapple"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('./data/fruit.csv',sep=';')\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bad7a18",
   "metadata": {},
   "source": [
    "2.数据预处理操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dcb3c1d0",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_mtix = df['fruit'].map(lambda line:line.replace(' ','').split(','))  #' ','' 把空格替换成空的    split:以逗号进行切分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "88d224e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0              [apple, banana]\n",
       "1      [Orange, banana, apple]\n",
       "2      [Orange, banana, grape]\n",
       "3               [grape, apple]\n",
       "4          [pineapple, Orange]\n",
       "5    [pineapple, banana, pear]\n",
       "6                [pear, apple]\n",
       "7        [pear, banana, grape]\n",
       "8           [grape, pineapple]\n",
       "Name: fruit, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_mtix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "83406d3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from mlxtend.preprocessing import TransactionEncoder\n",
    "# 定义规则 \n",
    "#使用TransactionEncoder对矩阵进行拟合，也就是转成bool矩阵，转成矩阵之前必须要保证fruit列里面的值为列表，所以上面做了split后就变成了列表的样子\n",
    "model_tae = TransactionEncoder()   \n",
    "# 将规则应用到数据上\n",
    "data_te = model_tae.fit_transform(df_mtix)\n",
    "# 转型\n",
    "df_te = pd.DataFrame(data=data_te,columns=model_tae.columns_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c1539c62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False,  True,  True, False, False, False],\n",
       "       [ True,  True,  True, False, False, False],\n",
       "       [ True, False,  True,  True, False, False],\n",
       "       [False,  True, False,  True, False, False],\n",
       "       [ True, False, False, False, False,  True],\n",
       "       [False, False,  True, False,  True,  True],\n",
       "       [False,  True, False, False,  True, False],\n",
       "       [False, False,  True,  True,  True, False],\n",
       "       [False, False, False,  True, False,  True]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_te"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5f407eb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Orange</th>\n",
       "      <th>apple</th>\n",
       "      <th>banana</th>\n",
       "      <th>grape</th>\n",
       "      <th>pear</th>\n",
       "      <th>pineapple</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Orange  apple  banana  grape   pear  pineapple\n",
       "0   False   True    True  False  False      False\n",
       "1    True   True    True  False  False      False\n",
       "2    True  False    True   True  False      False\n",
       "3   False   True   False   True  False      False\n",
       "4    True  False   False  False  False       True\n",
       "5   False  False    True  False   True       True\n",
       "6   False   True   False  False   True      False\n",
       "7   False  False    True   True   True      False\n",
       "8   False  False   False   True  False       True"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_te"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f2531707",
   "metadata": {},
   "source": [
    "3.建模"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9d2b2406",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>support</th>\n",
       "      <th>itemsets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.333333</td>\n",
       "      <td>(Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.444444</td>\n",
       "      <td>(apple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.555556</td>\n",
       "      <td>(banana)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.444444</td>\n",
       "      <td>(grape)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.333333</td>\n",
       "      <td>(pear)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.333333</td>\n",
       "      <td>(pineapple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(apple, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.222222</td>\n",
       "      <td>(banana, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(grape, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pineapple, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.222222</td>\n",
       "      <td>(banana, apple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(grape, apple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pear, apple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.222222</td>\n",
       "      <td>(banana, grape)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.222222</td>\n",
       "      <td>(pear, banana)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pineapple, banana)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pear, grape)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pineapple, grape)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pear, pineapple)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(banana, apple, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(banana, grape, Orange)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pear, banana, grape)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>0.111111</td>\n",
       "      <td>(pear, pineapple, banana)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     support                   itemsets\n",
       "0   0.333333                   (Orange)\n",
       "1   0.444444                    (apple)\n",
       "2   0.555556                   (banana)\n",
       "3   0.444444                    (grape)\n",
       "4   0.333333                     (pear)\n",
       "5   0.333333                (pineapple)\n",
       "6   0.111111            (apple, Orange)\n",
       "7   0.222222           (banana, Orange)\n",
       "8   0.111111            (grape, Orange)\n",
       "9   0.111111        (pineapple, Orange)\n",
       "10  0.222222            (banana, apple)\n",
       "11  0.111111             (grape, apple)\n",
       "12  0.111111              (pear, apple)\n",
       "13  0.222222            (banana, grape)\n",
       "14  0.222222             (pear, banana)\n",
       "15  0.111111        (pineapple, banana)\n",
       "16  0.111111              (pear, grape)\n",
       "17  0.111111         (pineapple, grape)\n",
       "18  0.111111          (pear, pineapple)\n",
       "19  0.111111    (banana, apple, Orange)\n",
       "20  0.111111    (banana, grape, Orange)\n",
       "21  0.111111      (pear, banana, grape)\n",
       "22  0.111111  (pear, pineapple, banana)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from mlxtend.frequent_patterns import fpgrowth\n",
    "from mlxtend.frequent_patterns import apriori\n",
    "from mlxtend.frequent_patterns import fpmax\n",
    "\n",
    "rules = apriori(df=df_te,min_support=0.1,use_colnames=True)\n",
    "rules"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a832347",
   "metadata": {},
   "source": [
    "4.模型评分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "471b8706",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>antecedents</th>\n",
       "      <th>consequents</th>\n",
       "      <th>antecedent support</th>\n",
       "      <th>consequent support</th>\n",
       "      <th>support</th>\n",
       "      <th>confidence</th>\n",
       "      <th>lift</th>\n",
       "      <th>leverage</th>\n",
       "      <th>conviction</th>\n",
       "      <th>zhangs_metric</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(apple)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>(apple)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>(apple)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>(apple)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>(banana, apple)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>(banana, Orange)</td>\n",
       "      <td>(apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>(apple, Orange)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(apple, Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>(apple)</td>\n",
       "      <td>(banana, Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(banana, apple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>(banana, grape)</td>\n",
       "      <td>(Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>(banana, Orange)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>(grape, Orange)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(grape, Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(banana, Orange)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>(Orange)</td>\n",
       "      <td>(banana, grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>(pear, banana)</td>\n",
       "      <td>(grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>(pear, grape)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>(banana, grape)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(banana, grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(pear, grape)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>(grape)</td>\n",
       "      <td>(pear, banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>(pear, pineapple)</td>\n",
       "      <td>(banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>(pear, banana)</td>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>(pineapple, banana)</td>\n",
       "      <td>(pear)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>(pear)</td>\n",
       "      <td>(pineapple, banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>(pineapple)</td>\n",
       "      <td>(pear, banana)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>(banana)</td>\n",
       "      <td>(pear, pineapple)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.111111</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            antecedents          consequents  antecedent support  \\\n",
       "0               (apple)             (Orange)                 NaN   \n",
       "1              (Orange)              (apple)                 NaN   \n",
       "2              (banana)             (Orange)                 NaN   \n",
       "3              (Orange)             (banana)                 NaN   \n",
       "4               (grape)             (Orange)                 NaN   \n",
       "5              (Orange)              (grape)                 NaN   \n",
       "6           (pineapple)             (Orange)                 NaN   \n",
       "7              (Orange)          (pineapple)                 NaN   \n",
       "8              (banana)              (apple)                 NaN   \n",
       "9               (apple)             (banana)                 NaN   \n",
       "10              (grape)              (apple)                 NaN   \n",
       "11              (apple)              (grape)                 NaN   \n",
       "12               (pear)              (apple)                 NaN   \n",
       "13              (apple)               (pear)                 NaN   \n",
       "14             (banana)              (grape)                 NaN   \n",
       "15              (grape)             (banana)                 NaN   \n",
       "16               (pear)             (banana)                 NaN   \n",
       "17             (banana)               (pear)                 NaN   \n",
       "18          (pineapple)             (banana)                 NaN   \n",
       "19             (banana)          (pineapple)                 NaN   \n",
       "20               (pear)              (grape)                 NaN   \n",
       "21              (grape)               (pear)                 NaN   \n",
       "22          (pineapple)              (grape)                 NaN   \n",
       "23              (grape)          (pineapple)                 NaN   \n",
       "24               (pear)          (pineapple)                 NaN   \n",
       "25          (pineapple)               (pear)                 NaN   \n",
       "26      (banana, apple)             (Orange)                 NaN   \n",
       "27     (banana, Orange)              (apple)                 NaN   \n",
       "28      (apple, Orange)             (banana)                 NaN   \n",
       "29             (banana)      (apple, Orange)                 NaN   \n",
       "30              (apple)     (banana, Orange)                 NaN   \n",
       "31             (Orange)      (banana, apple)                 NaN   \n",
       "32      (banana, grape)             (Orange)                 NaN   \n",
       "33     (banana, Orange)              (grape)                 NaN   \n",
       "34      (grape, Orange)             (banana)                 NaN   \n",
       "35             (banana)      (grape, Orange)                 NaN   \n",
       "36              (grape)     (banana, Orange)                 NaN   \n",
       "37             (Orange)      (banana, grape)                 NaN   \n",
       "38       (pear, banana)              (grape)                 NaN   \n",
       "39        (pear, grape)             (banana)                 NaN   \n",
       "40      (banana, grape)               (pear)                 NaN   \n",
       "41               (pear)      (banana, grape)                 NaN   \n",
       "42             (banana)        (pear, grape)                 NaN   \n",
       "43              (grape)       (pear, banana)                 NaN   \n",
       "44    (pear, pineapple)             (banana)                 NaN   \n",
       "45       (pear, banana)          (pineapple)                 NaN   \n",
       "46  (pineapple, banana)               (pear)                 NaN   \n",
       "47               (pear)  (pineapple, banana)                 NaN   \n",
       "48          (pineapple)       (pear, banana)                 NaN   \n",
       "49             (banana)    (pear, pineapple)                 NaN   \n",
       "\n",
       "    consequent support   support  confidence  lift  leverage  conviction  \\\n",
       "0                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "1                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "2                  NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "3                  NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "4                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "5                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "6                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "7                  NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "8                  NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "9                  NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "10                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "11                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "12                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "13                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "14                 NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "15                 NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "16                 NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "17                 NaN  0.222222         NaN   NaN       NaN         NaN   \n",
       "18                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "19                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "20                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "21                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "22                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "23                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "24                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "25                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "26                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "27                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "28                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "29                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "30                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "31                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "32                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "33                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "34                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "35                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "36                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "37                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "38                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "39                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "40                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "41                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "42                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "43                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "44                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "45                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "46                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "47                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "48                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "49                 NaN  0.111111         NaN   NaN       NaN         NaN   \n",
       "\n",
       "    zhangs_metric  \n",
       "0             NaN  \n",
       "1             NaN  \n",
       "2             NaN  \n",
       "3             NaN  \n",
       "4             NaN  \n",
       "5             NaN  \n",
       "6             NaN  \n",
       "7             NaN  \n",
       "8             NaN  \n",
       "9             NaN  \n",
       "10            NaN  \n",
       "11            NaN  \n",
       "12            NaN  \n",
       "13            NaN  \n",
       "14            NaN  \n",
       "15            NaN  \n",
       "16            NaN  \n",
       "17            NaN  \n",
       "18            NaN  \n",
       "19            NaN  \n",
       "20            NaN  \n",
       "21            NaN  \n",
       "22            NaN  \n",
       "23            NaN  \n",
       "24            NaN  \n",
       "25            NaN  \n",
       "26            NaN  \n",
       "27            NaN  \n",
       "28            NaN  \n",
       "29            NaN  \n",
       "30            NaN  \n",
       "31            NaN  \n",
       "32            NaN  \n",
       "33            NaN  \n",
       "34            NaN  \n",
       "35            NaN  \n",
       "36            NaN  \n",
       "37            NaN  \n",
       "38            NaN  \n",
       "39            NaN  \n",
       "40            NaN  \n",
       "41            NaN  \n",
       "42            NaN  \n",
       "43            NaN  \n",
       "44            NaN  \n",
       "45            NaN  \n",
       "46            NaN  \n",
       "47            NaN  \n",
       "48            NaN  \n",
       "49            NaN  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from mlxtend.frequent_patterns import association_rules  # 查看关联规则的所有指标(如支持度、置信度、提升度)\n",
    "\n",
    "rules_ar =association_rules(df=rules,metric='confidence',min_threshold=0.1,support_only=True)\n",
    "rules_ar"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
